home *** CD-ROM | disk | FTP | other *** search
- /* GadTools layout toolkit
- **
- ** Copyright © 1993-1995 by Olaf `Olsen' Barthel
- ** Freely distributable.
- */
-
- #include "gtlayout_global.h"
-
- LONG LIBENT
- LT_LabelWidth(REG(a0) LayoutHandle *handle,REG(a1) STRPTR label)
- {
- if(handle)
- {
- struct RastPort *rp = &handle -> RPort;
- LONG start;
- LONG len;
- LONG cnt;
- LONG width,maxWidth;
- LONG underscore;
-
- start = 0;
- maxWidth = 0;
- underscore = 0;
-
- cnt = 0;
- len = 0;
-
- while(label[len])
- {
- if(label[len] == '_')
- {
- if(!underscore)
- underscore = TextLength(rp,"_",1);
-
- cnt += underscore;
- }
-
- if(label[len] == '\n')
- {
- if(len > start)
- width = TextLength(rp,&label[start],len - start) - cnt;
- else
- width = 0;
-
- cnt = 0;
- start = len + 1;
-
- if(width > maxWidth)
- maxWidth = width;
- }
-
- len++;
- }
-
- if(len > start)
- width = TextLength(rp,&label[start],len - start) - cnt;
- else
- width = 0;
-
- if(width > maxWidth)
- maxWidth = width;
-
- return(maxWidth);
- }
- else
- return(0);
- }
-
-
- /*****************************************************************************/
-
-
- LONG LIBENT
- LT_LabelChars(REG(a0) LayoutHandle *handle,REG(a1) STRPTR label)
- {
- if(handle)
- return((LT_LabelWidth(handle,label) + handle -> GlyphWidth - 1) / handle -> GlyphWidth);
- else
- return(0);
- }
-